package com.tianqu.tms.www.cardect.action;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.itextpdf.text.Document;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.entity.TmsDetectNormal;
import com.tianqu.tms.www.cardect.controller.CarDetectPDFResultController;

public class CarDetectPDFResultAction extends TmsAction {
	 public static final String CARSERIAL="carSerial";
     private static final String NORMAL ="normal";
     private Logger logger = Logger.getLogger(CarDetectPDFResultAction.class);//log
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		//获得当前系统中PDF图片背景
		String URL = request.getSession().getServletContext().getRealPath("/")+"style/images/"+"jiancebaogao.jpg";
		logger.error(""+URL);
		String carSerial = request.getParameter(CARSERIAL);
		if(carSerial!=null){
			if(carSerial.trim().length()>0){
				CarDetectPDFResultController controller = new CarDetectPDFResultController();
				uc.setAttribute(CARSERIAL, carSerial);
				controller.execute(uc);
				TmsDetectNormal normal = (TmsDetectNormal) uc.getAttribute(NORMAL);
				if(normal!=null){
					getResponse(itext(carSerial,normal,URL),response);
					return null;
				}
			}
		}
		
		return null;
	}
    /**
     * pdf生成
     * @param serial
     * @param dto
     * @param url
     */
	public File itext(String serial,TmsDetectNormal dto,String url) {
		File file =new File(serial+".pdf");
		try {
          
			Document tDoc = new Document(PageSize.A4, 50, 50, 50, 50); // 创建文档
			PdfWriter tWriter = PdfWriter.getInstance(tDoc,new FileOutputStream(file)); // 创建写入流
			//加密
			// tWriter.setEncryption(null,"1".getBytes(),
			// PdfWriter.ALLOW_SCREENREADERS|PdfWriter.ALLOW_PRINTING,PdfWriter.STANDARD_ENCRYPTION_128);
			// //加密
			tDoc.open(); // 打开文档
			Image tImgCover = Image.getInstance(url);
			/* 设置图片的位置 */
			tImgCover.setAbsolutePosition(0, 0);
			/* 设置图片的大小 */
			tImgCover.scaleAbsolute(595, 842);
			tDoc.add(tImgCover); // 加载图片
			 //实例中文支持 
            BaseFont bf=BaseFont.createFont( "STSong-Light",  "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
			Font font = new Font(bf, 10);
			font.setStyle(Font.BOLD);
			font.getBaseFont();

			// 获得pdfstamper在当前页的上层打印内容.也就是说 这些内容会覆盖在原先的pdf内容之上.
			PdfContentByte over = tWriter.getDirectContent();

			//**********************************************************************左侧坐标开始************************************************/
			// 开始写入文本
			over.beginText();
			// 设置字体和大小
			over.setFontAndSize(font.getBaseFont(), 10);
			// 设置字体的输出位置(x,y)左下角0。0位置为起始坐标
			over.setTextMatrix(160, 136);
			//左前轮毂
			over.showText(IsNull(dto.getPanelFenerLhChk4()));
			over.endText();

			//左前轮胎
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 149);
			over.showText(IsNull(dto.getPanelFenerLhChk3()));
			over.endText();

			//左前翼子板
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 162);
			over.showText(IsNull(dto.getPanelFenerLhChk2()));
			over.endText();

			//前挡风玻璃
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 175);
			over.showText(IsNull(dto.getPanelFenerLhChk1()));
			over.endText();
			
			//左后玻璃窗升降功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 188);
			over.showText(IsNull(dto.getInsideChk30()));
			over.endText();

			//右后玻璃窗升降功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,201 );
			over.showText(IsNull(dto.getInsideChk29()));
			over.endText();
			
			//右前玻璃窗升降功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,214 );
			over.showText(IsNull(dto.getInsideChk28()));
			over.endText();

			//左前玻璃窗升降功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,227 );
			over.showText(IsNull(dto.getInsideChk27()));
			over.endText();
			//右后视镜功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,240 );
			over.showText(IsNull(dto.getInsideChk26()));
			over.endText();

			//左后视镜功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 253);
			over.showText(IsNull(dto.getInsideChk25()));
			over.endText();
			//雨刷功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,266 );
			over.showText(IsNull(dto.getInsideChk24()));
			over.endText();

			//音响系统
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,279 );
			over.showText(IsNull(dto.getInsideChk23()));
			over.endText();
			//空调系统工作
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 292);
			over.showText(IsNull(dto.getInsideChk22()));
			over.endText();

			//驻车制动功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 305);
			over.showText(IsNull(dto.getInsideChk21()));
			over.endText();
			//变速箱换挡功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,318 );
			over.showText(IsNull(dto.getInsideChk20()));
			over.endText();

			//室内照明灯功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,331 );
			over.showText(IsNull(dto.getInsideChk19()));
			over.endText();
			//室外照明灯功能
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 344);
			over.showText(IsNull(dto.getInsideChk18()));
			over.endText();

			//机油压力故障灯（内饰）	
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 357);
			over.showText(IsNull(dto.getInsideChk17()));
			over.endText();
			//ABS故障灯
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 370);
			over.showText(IsNull(dto.getInsideChk16()));
			over.endText();

			//气囊故障灯
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 383);
			over.showText(IsNull(dto.getInsideChk15()));
			over.endText();
			//发动机故障灯（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 396);
			over.showText(IsNull(dto.getInsideChk14()));
			over.endText();

			//仪表盘（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 409);
			over.showText(IsNull(dto.getInsideChk13()));
			over.endText();
			//发动机运转声音（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 422);
			over.showText(IsNull(dto.getInsideChk12()));
			over.endText();

			//安全带功能（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 435);
			over.showText(IsNull(dto.getInsideChk11()));
			over.endText();
			//左B支柱内饰（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 448);
			over.showText(IsNull(dto.getInsideChk10()));
			over.endText();

			//左A支柱内饰（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 461);
			over.showText(IsNull(dto.getInsideChk9()));
			over.endText();
			//储物盒（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,474 );
			over.showText(IsNull(dto.getInsideChk8()));
			over.endText();

			//车顶内饰（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 487);
			over.showText(IsNull(dto.getInsideChk7()));
			over.endText();
			//车内后视镜（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 500);
			over.showText(IsNull(dto.getInsideChk6()));
			over.endText();

			//右遮阳板（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,513 );
			over.showText(IsNull(dto.getInsideChk5()));
			over.endText();
			

			//左遮阳板（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 526);
			over.showText(IsNull(dto.getInsideChk4()));
			over.endText();
			//驾驶舱前护板（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,539 );
			over.showText(IsNull(dto.getInsideChk3()));
			over.endText();

			//左前座椅（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 552);
			over.showText(IsNull(dto.getInsideChk2()));
			over.endText();
			//左前地毯（内饰）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 565);
			over.showText(IsNull(dto.getInsideChk1()));
			over.endText();

			//左侧中部车身纵梁(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,578 );
			over.showText(IsNull(dto.getFrontLeftChk9()));
			over.endText();
			//左前车身底盘(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,591);
			over.showText(IsNull(dto.getFrontLeftChk8()));
			over.endText();

			//左前车身底板(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,604 );
			over.showText(IsNull(dto.getFrontLeftChk7()));
			over.endText();
			//左前门下边沿(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,617 );
			over.showText(IsNull(dto.getFrontLeftChk6()));
			over.endText();

			//左前门玻璃(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 630);
			over.showText(IsNull(dto.getFrontLeftChk5()));
			over.endText();
			//左前门内饰(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 643);
			over.showText(IsNull(dto.getFrontLeftChk4()));
			over.endText();

			//左前门左B柱(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,656 );
			over.showText(IsNull(dto.getFrontLeftChk3()));
			over.endText();
			//左前门左A柱(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160, 669);
			over.showText(IsNull(dto.getFrontLeftChk2()));
			over.endText();

			//左前门(左前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(160,682 );
			over.showText(IsNull(dto.getFrontLeftChk1()));
			over.endText();
			
			//车辆ID写入
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(70, 718);
			over.showText(IsNull(serial));
			over.endText();

			//检测日期写入
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(70, 760);
			over.showText(TimestampToString(dto.getChkTime()));
			over.endText();
			//*****************************************************************左侧坐标设置结束******************************************************************/
			
			
			
			
			//**********************************************************************中部坐标开始************************************************/
			// 开始写入文本
			over.beginText();
			// 设置字体和大小
			over.setFontAndSize(font.getBaseFont(), 10);
			// 设置字体的输出位置(x,y)左下角0。0位置为起始坐标
			over.setTextMatrix(345, 136);
			//右C支柱内饰(右后门)
			over.showText(IsNull(dto.getRearRightChk8()));
			over.endText();

			//右后座椅(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 149);
			over.showText(IsNull(dto.getRearRightChk7()));
			over.endText();

			//右后地毯(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 162);
			over.showText(IsNull(dto.getRearRightChk6()));
			over.endText();

			//右后门玻璃(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 175);
			over.showText(IsNull(dto.getRearRightChk5()));
			over.endText();
			
			//右后门内饰(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 188);
			over.showText(IsNull(dto.getRearRightChk4()));
			over.endText();

			//右C柱(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,201 );
			over.showText(IsNull(dto.getRearRightChk3()));
			over.endText();
			
			//右B柱(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,214 );
			over.showText(IsNull(dto.getRearRightChk2()));
			over.endText();

			//右后门(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,227 );
			over.showText(IsNull(dto.getRearRightChk1()));
			over.endText();
			
			
			//右侧中部车身纵梁(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,240 );
			over.showText(IsNull(dto.getFrontRightChk13()));
			over.endText();

			//右前车身底盘(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 253);
			over.showText(IsNull(dto.getFrontRightChk12()));
			over.endText();
			//右前车身底板(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,266 );
			over.showText(IsNull(dto.getFrontRightChk11()));
			over.endText();

			//右前门下边沿(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,279 );
			over.showText(IsNull(dto.getFrontRightChk10()));
			over.endText();
			//右B支柱内饰(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 292);
			over.showText(IsNull(dto.getFrontRightChk9()));
			over.endText();

			//右A支柱内饰(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 305);
			over.showText(IsNull(dto.getFrontRightChk8()));
			over.endText();
			//右前座椅(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,318 );
			over.showText(IsNull(dto.getFrontRightChk7()));
			over.endText();

			//右前地毯(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,331 );
			over.showText(IsNull(dto.getFrontRightChk6()));
			over.endText();
			//右前门玻璃(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 344);
			over.showText(IsNull(dto.getFrontRightChk5()));
			over.endText();

			//右前门内饰(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 357);
			over.showText(IsNull(dto.getFrontRightChk4()));
			over.endText();
			//右B柱(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 370);
			over.showText(IsNull(dto.getFrontRightChk3()));
			over.endText();

			//右A柱(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 383);
			over.showText(IsNull(dto.getFrontRightChk2()));
			over.endText();
			//右前门(右前门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 396);
			over.showText(IsNull(dto.getFrontRightChk1()));
			over.endText();

			//右前减震器（右前翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 409);
			over.showText(IsNull(dto.getPanelFenerRhChk6()));
			over.endText();
			//右前翼子板内衬（右前翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 422);
			over.showText(IsNull(dto.getPanelFenerRhChk5()));
			over.endText();

			//右前轮毂（右前翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 435);
			over.showText(IsNull(dto.getPanelFenerRhChk4()));
			over.endText();
			//右前轮胎（右前翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 448);
			over.showText(IsNull(dto.getPanelFenerRhChk3()));
			over.endText();

			//右前翼子板（右前翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 461);
			over.showText(IsNull(dto.getPanelFenerRhChk2()));
			over.endText();
			//前挡风玻璃（右前翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,474 );
			over.showText(IsNull(dto.getPanelFenerRhChk1()));
			over.endText();

			//右前减震悬挂(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 487);
			over.showText(IsNull(dto.getEngineChk8()));
			over.endText();
			//左前减震悬挂(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 500);
			over.showText(IsNull(dto.getEngineChk7()));
			over.endText();

			//发动机舱内右侧护板(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,513 );
			over.showText(IsNull(dto.getEngineChk6()));
			over.endText();
			

			//发动机舱内左侧护板(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 526);
			over.showText(IsNull(dto.getEngineChk5()));
			over.endText();
			//右侧前部纵梁(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,539 );
			over.showText(IsNull(dto.getEngineChk4()));
			over.endText();

			//左侧前部纵梁(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 552);
			over.showText(IsNull(dto.getEngineChk3()));
			over.endText();
			//水箱框架(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 565);
			over.showText(IsNull(dto.getEngineChk2()));
			over.endText();

			//前防撞梁(发动机仓)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,578 );
			over.showText(IsNull(dto.getEngineChk1()));
			over.endText();
			
			
			//前下边沿(正前面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,591);
			over.showText(IsNull(dto.getDeadAheadChk6()));
			over.endText();

			//进气格栅(正前面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,604 );
			over.showText(IsNull(dto.getDeadAheadChk5()));
			over.endText();
			//发动机舱盖(正前面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,617 );
			over.showText(IsNull(dto.getDeadAheadChk4()));
			over.endText();

			//前保险杠(正前面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 630);
			over.showText(IsNull(dto.getDeadAheadChk3()));
			over.endText();
			//右前大灯(正前面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 643);
			over.showText(IsNull(dto.getDeadAheadChk2()));
			over.endText();

			//左前大灯(正前面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,656 );
			over.showText(IsNull(dto.getDeadAheadChk1()));
			over.endText();
			
			
			//左前减震器(左前翼子板)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345, 669);
			over.showText(IsNull(dto.getPanelFenerLhChk6()));
			over.endText();

			//左前翼子板内衬(左前翼子板)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(345,682 );
			over.showText(IsNull(dto.getPanelFenerLhChk5()));
			over.endText();
			//**********************************************************************中部坐标结束************************************************/
			

			//**********************************************************************右侧坐标开始************************************************/
			// 开始写入文本
			over.beginText();
			// 设置字体和大小
			over.setFontAndSize(font.getBaseFont(), 10);
			// 设置字体的输出位置(x,y)左下角0。0位置为起始坐标
			over.setTextMatrix(525, 136);
			//车顶
			over.showText(IsNull(dto.getRearLeftChk11()));
			over.endText();
		
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 149);
			over.showText(IsNull(dto.getRearLeftChk11()));
			over.endText();

			//左后车身底板(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 162);
			over.showText(IsNull(dto.getRearLeftChk10()));
			over.endText();

			//左后门下边沿(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 175);
			over.showText(IsNull(dto.getRearLeftChk9()));
			over.endText();

			//左C支柱内饰(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 188);
			over.showText(IsNull(dto.getRearLeftChk8()));
			over.endText();
			
			//左后座椅(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 201);
			over.showText(IsNull(dto.getRearLeftChk7()));
			over.endText();

			//左后地毯(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,214 );
			over.showText(IsNull(dto.getRearLeftChk6()));
			over.endText();
			
			//左后门玻璃(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,227 );
			over.showText(IsNull(dto.getRearLeftChk5()));
			over.endText();

			//左后门内饰(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,240 );
			over.showText(IsNull(dto.getRearLeftChk4()));
			over.endText();
			
			
			//左C住(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,253 );
			over.showText(IsNull(dto.getRearLeftChk3()));
			over.endText();

			//左B柱(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 266);
			over.showText(IsNull(dto.getRearLeftChk2()));
			over.endText();
			//左后门(左后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,279 );
			over.showText(IsNull(dto.getRearLeftChk1()));
			over.endText();

			//左后减震器（左后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,292 );
			over.showText(IsNull(dto.getFenderLaChk6()));
			over.endText();
			//左后翼子板内衬（左后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 305);
			over.showText(IsNull(dto.getFenderLaChk5()));
			over.endText();

			//左后轮毂（左后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 318);
			over.showText(IsNull(dto.getFenderLaChk4()));
			over.endText();
			//左后轮胎（左后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,331 );
			over.showText(IsNull(dto.getFenderLaChk3()));
			over.endText();

			//左后翼子板（左后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,344 );
			over.showText(IsNull(dto.getFenderLaChk2()));
			over.endText();
			//后挡风玻璃（左后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 357);
			over.showText(IsNull(dto.getFenderLaChk1()));
			over.endText();

			//行李箱内侧底板(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 370);
			over.showText(IsNull(dto.getLuggageChk10()));
			over.endText();
			//备胎(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 383);
			over.showText(IsNull(dto.getLuggageChk9()));
			over.endText();

			//右侧后部纵梁(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 396);
			over.showText(IsNull(dto.getLuggageChk8()));
			over.endText();
			//左侧后部纵梁(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 409);
			over.showText(IsNull(dto.getLuggageChk7()));
			over.endText();

			//三角警示牌(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 422);
			over.showText(IsNull(dto.getLuggageChk6()));
			over.endText();
			//千斤顶(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 435);
			over.showText(IsNull(dto.getLuggageChk5()));
			over.endText();

			//右后减震悬挂(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 448);
			over.showText(IsNull(dto.getLuggageChk4()));
			over.endText();
			//左后减震悬挂(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 461);
			over.showText(IsNull(dto.getLuggageChk3()));
			over.endText();

			//行李箱内右侧护板(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 474);
			over.showText(IsNull(dto.getLuggageChk2()));
			over.endText();
			//行李箱内左侧护板(行李箱内)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,487 );
			over.showText(IsNull(dto.getLuggageChk1()));
			over.endText();

			//后防撞梁(正后面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 500);
			over.showText(IsNull(dto.getRightAsternChk6()));
			over.endText();
			//后下边沿(正后面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 513);
			over.showText(IsNull(dto.getRightAsternChk5()));
			over.endText();

			//后保险杠(正后面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,526 );
			over.showText(IsNull(dto.getRightAsternChk4()));
			over.endText();
			

			//行李箱盖(正后面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 539);
			over.showText(IsNull(dto.getRightAsternChk3()));
			over.endText();
			//右后尾灯(正后面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,552 );
			over.showText(IsNull(dto.getRightAsternChk2()));
			over.endText();

			//左后尾灯(正后面)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 565);
			over.showText(IsNull(dto.getRightAsternChk1()));
			over.endText();
			//右后减震器（右后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 578);
			over.showText(IsNull(dto.getFenderRaChk6()));
			over.endText();

			//右后翼子板内衬（右后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,591 );
			over.showText(IsNull(dto.getFenderRaChk5()));
			over.endText();
			//右后轮毂（右后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,604);
			over.showText(IsNull(dto.getFenderRaChk4()));
			over.endText();

			//右后轮胎（右后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,617 );
			over.showText(IsNull(dto.getFenderRaChk3()));
			over.endText();
			//右后翼子板（右后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,630 );
			over.showText(IsNull(dto.getFenderRaChk2()));
			over.endText();

			//后挡风玻璃（右后翼子板）
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 643);
			over.showText(IsNull(dto.getFenderRaChk1()));
			over.endText();
			
			
			//右后车身底盘(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 656);
			over.showText(IsNull(dto.getRearRightChk11()));
			over.endText();

			//右后车身底板(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525,669 );
			over.showText(IsNull(dto.getRearRightChk10()));
			over.endText();
			
			
			//右后门下边沿(右后门)
			over.beginText();
			over.setFontAndSize(font.getBaseFont(), 10);
			over.setTextMatrix(525, 682);
			over.showText(IsNull(dto.getRearRightChk9()));
			over.endText();

			//**********************************************************************右侧坐标结束************************************************/
			

			
			//事故车
			if(StringToInt(dto.getDisasterCars())==1){
				//水淹
				over.beginText();
				over.setFontAndSize(font.getBaseFont(), 12);
				over.setTextMatrix(459, 715);
				over.showText(IsNull("√"));
				over.endText();
			}else if(StringToInt(dto.getDisasterCars())==2){
				//火灾
				over.beginText();
				over.setFontAndSize(font.getBaseFont(), 12);
				over.setTextMatrix(501, 715);
				over.showText(IsNull("√"));
				over.endText();
			}else if(StringToInt(dto.getDisasterCars())==3){
				//盐害
				over.beginText();
				over.setFontAndSize(font.getBaseFont(), 12);
				over.setTextMatrix(542, 715);
				over.showText(IsNull("√"));
				over.endText();
			}
		
			
			tDoc.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return file;
	}
	/**
	 * 空转”“
	 * @return
	 * @throws Exception
	 */
	private String IsNull(String st)throws Exception{
		if(st!=null){
			return st;
		}else{
			return " ";
		}
	}
	
	/**
	 * 转型
	 * @param st
	 * @return
	 */
	private int StringToInt(String st){
		if(st==null||st.equals(" ")){
			return 0;
		}else{
			return Integer.valueOf(st);
		}
	}
	
	
	/**
	 * 日期格式转型
	 * @param tmp
	 * @return
	 */
	private  String TimestampToString(Timestamp tmp) {
		Date currentTime = tmp;
		 SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
		return format.format(currentTime);
	}
	

}
